import axios from '@/libs/api.request';
import { getToken } from '@/libs/util';
class Authorization {
  constructor() {
    this.$axios = axios;
  }

  /**
   * 第一层分页查询
   * @param param
   * @returns {AxiosPromise}
   */
  queryToplayerPage = (param) => {
    return axios.request({
      url: '/admin/authorization/query/extent/page',
      method: 'post',
      dataType: 'json',
      headers: {
        'Content-Type': 'application/json; charset=UTF-8',
        'token': getToken()
      },
      data: param
    })
  }

  /**
   * 根据parentId查子机构
   * @param param
   * @returns {*}
   */
   queryChildrens = (param) => {
    console.log(param);
    return axios.request({
      url: '/admin/authorization/query/list/where',
      method: 'post',
      dataType: 'json',
      headers: {
        'Content-Type': 'application/json; charset=UTF-8',
        'token': getToken()
      },
      data: param
    });
  }

  /**
   * 查询所有的菜单权限
   * @returns {AxiosPromise}
   */
  queryDepthChildrens = () => {
    return axios.request({
      url: '/admin/authorization/query/depthChildrens',
      method: 'get',
      dataType: 'json',
      headers: {
        'Content-Type': 'application/json; charset=UTF-8',
        'token': getToken()
      }
    })
  }
  queryPage = (param) => {
    return axios.request({
      url: '/admin/authorization/query/page/',
      method: 'post',
      dataType: 'json',
      headers: {
        'Content-Type': 'application/json; charset=UTF-8',
        'token': getToken()
      },
      data: param
    })
  }
  add = (param) => {
    return axios.request({
      url: '/admin/authorization/add/',
      method: 'post',
      dataType: 'json',
      headers: {
        'Content-Type': 'application/json; charset=UTF-8',
        'token': getToken()
      },
      data: param
    })
  }

  update = (param) => {
    return axios.request({
      url: '/admin/authorization/update/',
      method: 'post',
      dataType: 'json',
      headers: {
        'Content-Type': 'application/json; charset=UTF-8',
        'token': getToken()
      },
      data: param
    })
  }

  remove = (param) => {

    let result =  axios.request({
      url: '/admin/authorization/delete/',
      method: 'post',
      dataType: 'json',
      headers: {
        'Content-Type': 'application/json; charset=UTF-8',
        'token': getToken()
      },
      data: param
    })
    return result;
  }


}
export default Authorization;
